package com.cxx.purchasecharge.dal;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.cxx.purchasecharge.core.model.persistence.Payment;
import com.cxx.purchasecharge.dal.common.GenericCRUDDao;

@Transactional
public interface PaymentDao extends GenericCRUDDao <Payment, Long>, PaymentDaoPlus
{

    public Payment findById (long id);

    public List <Payment> findByOrderId (long orderId);

    @Query (value = "select p from Payment p where p.customer.id=?1 order by p.paidDate desc")
    public List <Payment> findByCustomerId (long customerId);
    
    @Query (value = "select p from Payment p where p.customer.id=?1 and p.paidDate between ?2 and ?3 order by p.paidDate desc")
    public List <Payment> findByAdvance (long customerId, Date start, Date end);

}
